import React from "react";
import PropTypes from "prop-types";
import Item from "./Item";

/**
 * Navigation Component
 */
export default class Menu extends React.Component
{
    /**
     * 组件类名
     */
    class = "menu-nav";

    /**
     * 默认属性
     */
    static defaultProps =
    {
        class : "",
        items : [],
        style : {}
    };

    /**
     * 属性类型
     */
    static propTypes =
    {
        class : PropTypes.string,
        items : PropTypes.arrayOf(PropTypes.element),
        style : PropTypes.object
    };

    /**
     * 将要挂载组件
     */
    componentWillMount()
    {
        if (this.props.class) {
            this.class += " " + this.props.class;
        }
    }

    render()
    {
        return <ul className={this.class} style={this.props.style}>
            {this.props.items.map((value, index) => <Item key={index}>{value}</Item>)}
        </ul>
    }
}